package com.example.admin.controller.sys.validata;


import com.example.core.validations.DataValidator;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.Map;

@Scope("prototype")
@Component
public class TestValidata extends DataValidator<Map> {


    public TestValidata() {
        super(Map.class);
    }

    @Override
    public void validate() {
        assertTrue(x->(Boolean)x.get("assertTrue"),"Boolean 验证");
        notNull(x->x.get("notNull"),"null 对象验证");
        notEmpty(x->(String)x.get("notEmpty"),"空串验证");
        maxValue(x->x.get("maxValue"),10,"最大值验证");
        minValue(x->x.get("minValue"),5,"最小值验证");
        minMaxValue(x->x.get("minMaxValue"),5,8,"最小值最大值之间验证");
        maxLen(x->(String)x.get("maxLen"),5,"最大长度验证");
        minMaxLen(x->(String)x.get("minMaxLen"),5,10,"最大长度最小长度之间验证");
        isPhone(x->(String)x.get("phone"),"手机号验证");
        isEmail(x->(String)x.get("email"),"邮箱验证");
        isIdCard(x->(String)x.get("idCard"),"身份证验证");
        inList(x->x.get("list"),new Object[]{"正确","失败"},"数组验证");
    }


}
